﻿using System;

namespace Clock
{
    public class ClockEventArgs
    {
        public int Hour { get; set; }
        public int Minute { get; set; }
        public int Second { get; set; }
    }

 
    public class Clock
    {
        public delegate void ClockTickHandler(object tick, ClockEventArgs args);
        public delegate void ClockAlarmHandler(object alarm, ClockEventArgs args);

        public event ClockTickHandler OnTick;
        public event ClockAlarmHandler OnAlarm;

        public void Tick(int hour, int minute, int second)
        {
            Console.WriteLine("Clock is on " + hour + "时" + minute + "分" + second + "秒");
            ClockEventArgs args = new ClockEventArgs()
            {
                Hour = hour,
                Minute = minute,
                Second = second
            };
            OnTick(this, args);
        }

        public void Alarm(int hour, int minute, int second)
        {
            Console.WriteLine("Clock is on " + hour + "时" + minute + "分" + second + "秒");
            ClockEventArgs args = new ClockEventArgs()
            {
                Hour = hour,
                Minute = minute,
                Second = second
            };
            OnAlarm(this, args);
        }
    }

    public class Form
    {
        public Clock clock = new Clock();
        public void Clock_OnTick(object clock, ClockEventArgs args)
        {
            Console.WriteLine("Clock tick!");
        }
        public void Clock_OnAlarm(object clock, ClockEventArgs args)
        {
            Console.WriteLine("Clock alarm!");
        }
        public Form()
        {
            clock.OnTick += new Clock.ClockTickHandler(Clock_OnTick);
            clock.OnAlarm += new Clock.ClockAlarmHandler(Clock_OnAlarm);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Form form = new Form();
            form.clock.Tick(17, 21, 54);
            form.clock.Alarm(19, 57, 23);
        }
    }
}
